<template>
	<!-- 职位详情 -->
	<view class="">
		<u-navbar title="职位详情">
			<view class="pr20 x-fc color-ddd" slot="right">
				<view class="cuIcon-favorfill fs38 fw-w " @tap="blcollectionPosition()"
					:class="{'color-fs':data.is_collection!=0}"></view>
				<view class="cuIcon-share fs34 ml50 color-zs" @tap="shareShow=true"></view>
			</view>
		</u-navbar>
		<view class="box pb166 ml20 mr20 ">
			<!-- 头部 -->
			<view class="pl20 pr20 mt40 jobitem pt32">
				<view class="w240 h104 VIPbox pr">
					<image src="/static/img/index/11bule-6.png" style="top: 0;left: 0;" class="w-max h-max pa"
						mode="widthFix"></image>
					<text class="pr" style="z-index: 4;">最高结算：<text
							style="color: #FE495D;">{{data.post_subsidy}}</text>元/月</text>
				</view>
				<view class="flex row-column">
					<view class="jobtit mb20">{{data.title||'职位名称'}}</view>
					<!-- salary -->
					<view class="salary mt10" v-if='data.price==0&&data.price_end==0'>面议</view>
					<view class="salary mt10" v-else>{{data.price||0}}-{{data.price_end||0}}元</view>
				</view>
				<view class="flex mt40 mb32">
					<u-icon name="map-fill"></u-icon>
					<view class="h40 jobitem-middle mr14 ml14">{{data.city}}</view>
				</view>

				<view class="flex row-between col-center">
					<!-- 左边 -->
					<view class="flex1">
						<u-line-progress active-color="#2979ff" :percent="lineProgress"></u-line-progress>
						<view class="flex row-between mt16">
							<text
								class="peopNum">已报名{{data.fictitious_num+data.sign_num>=data.num?data.num:data.fictitious_num+data.sign_num||0}}人</text>
							<text class="peopNum">招聘{{data.num||0}}人</text>
						</view>
					</view>
				</view>
				<view class="h2 line mt40"></view>
			</view>
			<!-- 头部 -->

			<!-- 主体 -->
			<view class="banner pl28 pt32 pr10">
				<view class="">
					<view class="bannertit">
						职位详情
					</view>
					<view class="flex mt36 mb32 u-flex-wrap">
						<view class="w102 h40 jobitem-middle mr14" v-for="(item,index) in data.category_name"
							:key="index">{{item}}</view>
					</view>

					<view class="bannerInfo">
						<view class="">
							<u-parse :html="data.content"></u-parse>
						</view>
					</view>
				</view>

				<!-- <view class="mt40 mb20">VIP服务</view> -->
				<!-- VIP服务组件 -->
				<VIPservice class="mt40" />
				<!-- /VIP服务组件 -->

				<!-- 企业信息 -->
				<view class="enterpriseinfo mb40 mt60" @click="$jump('/pages/home/qiyeInfo/qiyeInfo')">
					<view class="">
						<view class="bannertit mb40 mt44">
							企业信息
						</view>
						<view class="flex row-between">
							<!-- 左边企业图标盒子 -->
							<view class="mr24">
								<image :src="$baseUrl+ data.logo_image" class="w120 h120"></image>
							</view>
							<!-- //左边企业图标盒子 -->

							<!-- 右边的盒子 -->
							<view class="flex row-between flex1">
								<view class="flex row-column row-between">
									<text>{{data.enterprise_name}}</text>
									<view class="">
										{{data.enterprise_type}}
									</view>
								</view>
								<u-icon name="arrow-right"></u-icon>
							</view>
							<!--// 右边的盒子 -->
						</view>
					</view>
					<!-- 地图 -->
					<view class="w662 h207 mapBox mt28 flex pl26 pr26 row-between" v-if="type==2" @tap.stop="goMap()">
						<!-- 左 -->
						<view class="flex col-center mr40 ">
							<view class="flex col-center mapadd">
								<image src="../../../static/img/index/11blue-posi.png" class="w18 h26"></image>
								<view class="ml20">{{data.position}}</view>
							</view>
							<view class="mt26 mapaddTop">
								<!-- {{data.city}} -->
							</view>
						</view>
						<!-- 右 -->
						<view class=" flex col-center">
							<view class="flex row-column mr10 flex1 col-center">
								<image src="/static/img/index/11blue-nav.png" class="w34 h34"></image>
								<view class="mt10 fs16">地图/导航</view>
							</view>
							<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
					<!-- 地图 -->
				</view>
				<!-- /企业信息 -->
			</view>
			<!-- 主体 -->


		</view>
		<!-- 底部 -->
		<view class="footerBox flex row-between pl60 pr20 pt20 pb20 col-center">
			<view class="flex row-column col-center" @tap="$tool.phone(data.iphone)">
				<image src="/static/img/index/liepinTell.png" mode="" class="w56 h56"></image>
				<text>打电话</text>
			</view>
			<view class="flex row-column col-center" @click="gotoService">
				<image src="/static/img/index/3liepin-liao.png" mode="" class="w56 h56"></image>
				<text>聊一聊</text>
			</view>
			<view class="w400 h80 footerBtn" @tap="applyCollar()">
				申请职位
			</view>
		</view>
		<!-- /底部 -->
		<u-popup v-model="shareShow" mode="bottom" borderRadius="32" :closeable="true" width="540">
			<view class="p72r bg-fff flex">
				<!-- <view class="tc fs40">分享到</view> -->
				<view class="x-ac mt30 mr30">
					<view class="y-fc" @tap="share(1)">
						<image src="/static/img/index/share1.png" class="w72r" mode="widthFix"></image>
						<view class="mt10r">微信好友</view>
					</view>
				</view>
				<view class="x-ac mt30">
					<view class="y-fc" @tap="share(2)">
						<image src="/static/img/index/share2.png" class="w72r" mode="widthFix"></image>
						<view class="mt10r">朋友圈</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import VIPservice from '@/components/VIPservice.vue'
	export default {
		name: 'jobDetail',
		components: {
			VIPservice
		},
		data() {
			return {
				shareShow: false,
				type: '',
				id: '',
				data: {},
				lineProgress: null
			};
		},
		onNavigationBarButtonTap(e) {
			console.log(e);
		},
		onLoad(e) {
			console.log(e)
			//蓝领进入type==2
			this.type = e.type
			this.id = e.id
			this.collarDetails()
		},
		onShow() {

		},
		methods: {
			share(e) {
				let that = this
				// e=1是分享微信好友 ,2是朋友圈
				let shareType = ''
				e == 1 ? shareType = 'WXSceneSession' : shareType = 'WXSceneTimeline'
				uni.share({
					provider: "weixin",
					scene: shareType,
					title: '预订美好app' + this.data.title + '正在热招',
					type: 0,
					href: this.$baseUrl + '/h5/#/pages/common/jobDetail/jobDetail?id=' + this.id + '&type=' + this
						.type,
					imageUrl: '/static/LOGO.png',
					summary: '预订美好app' + this.data.title + '正在热招',
					success: function(res) {
						console.log("success:" + JSON.stringify(res));
						that.shareShow = false
						that.$msg('分享成功')
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
						that.shareShow = false
						that.$msg('分享失败')
					}
				});
			},
			collarDetails() { //详情
				console.log(this.type)
				let api = ''
				if (this.type == 2) {
					api = 'collarDetails'
				} else if (this.type == 1) {
					api = 'reindexDetails'
				} else if (this.type == 3) {
					api = 'indexDetails'
				}
				this.$api[api]({
					id: this.id
				}).then(res => {
					this.data = res.data
					uni.setStorageSync('enterpriseDetail', res.data)
					let line = null
					line = ((res.data.sign_num + res.data.fictitious_num >= res.data.num ? res.data.num : res.data
						.sign_num + res.data.fictitious_num) / res.data.num).toFixed(2)
					this.lineProgress = line * 100
				})
			},
			applyCollar() { //申请职位
				console.log(this.type)
				let api = ''
				if (this.type == 2) {
					api = 'applyCollar'
				} else if (this.type == 1) {
					api = 'applyPosition'
				} else if (this.type == 3) {
					api = 'inapplyPosition'
				}
				this.$api[api]({
					id: this.id
				}).then(res => {
					this.$msg(res.msg)
					setTimeout(() => {
						this.collarDetails()
					}, 1000)
				}).catch(err => {
					console.log(err)
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/my/resume/resume'
						})
					}, 1000)
				})
			},
			blcollectionPosition() { //收藏/取消收藏蓝领职位
				let api = ''
				if (this.type == 2) { //蓝领
					api = 'blcollectionPosition'
				} else if (this.type == 1) { ////猎聘
					api = 'collectionPosition'
				} else if (this.type == 3) {
					api = 'incollectionPosition'
				}
				this.$api[api]({
					id: this.id
				}).then(res => {
					this.$msg(res.msg)
					this.collarDetails()
					// setTimeout(() => {
					// }, 1000)
				})
			},
			goMap() {
				var dst = new plus.maps.Point(this.data.longitude || 0, this.data.latitude || 0);
				// var src = new plus.maps.Point(this.data.myX, this.data.myY); 
				// 调用系统地图显示 
				plus.maps.openSysMap(dst, this.data.position, dst);
			},
			gotoService() {
				uni.switchTab({
					url: '/pages/msg/msg'
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F9F9F9;
	}

	.box {
		background: #FFFFFF;

		.jobitem {
			position: relative;
			border-radius: 14rpx;

			.jobtit {
				font-size: 30rpx;
				color: #0C162E;
			}

			.jobitem-middle {
				text-align: center;
				line-height: 40rpx;
				border-radius: 6rpx;
				font-size: 22rpx;
				color: #6D788B;
			}

			.salary {
				font-size: 34rpx;
				color: #FF286A;
			}

			.peopNum {
				font-size: 22rpx;
				color: #6D788B;
			}

			.jobitem-btn {
				text-align: center;
				line-height: 54rpx;
				background: #1385FF;
				border-radius: 10rpx;
				color: #FFFFFF;
			}

			.line {
				width: 100%;
				height: 2rpx;
				background: #D2DEEB;
			}
		}

		.banner {
			.bannertit {
				font-size: 30rpx;
				color: #0C162E;
				position: relative;
			}

			.bannertit::after {
				content: '';
				width: 120rpx;
				height: 10rpx;
				background: #1385FF;
				opacity: 0.3;
				position: absolute;
				left: 0;
				bottom: 0;
			}

			.jobitem-middle {
				text-align: center;
				line-height: 40rpx;
				background: #F1F3F5;
				border-radius: 6rpx;
				font-size: 22rpx;
				color: #6D788B;
			}

			.bannerInfo {

				.bannerInfotit,
				.bannerInfoList {
					font-size: 22rpx;
					color: #1385FF;
				}

				.bannerInfoList {
					color: #0C162E;
				}
			}

			.enterpriseinfo {
				image {
					width: 100%;
					height: 100%;
				}

				.mapBox {
					background: url('~@/static/img/index/11bule-BG.png') no-repeat;
					background-size: 100% 100%;

					.mapadd {
						font-size: 26rpx;
						color: #000000;
					}

					.mapaddTop {
						font-size: 20rpx;
						color: #454545;
					}
				}
			}

		}

	}

	.footerBox {
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		background-color: #FFFFFF;

		.footerBtn {
			background: #1385FF;
			border-radius: 40rpx;
			font-size: 30rpx;
			font-weight: 500;
			color: #FFFFFF;
			text-align: center;
			line-height: 80rpx;
		}
	}

	.VIPbox {
		position: absolute;
		right: 0;
		top: 0;
		background-image: url('/static/img/index/11bule-6.png');
		background-size: 100% 100%;
		font-size: 22rpx;
		color: #A24301;
		text-align: center;
		line-height: 140rpx;
	}
</style>
